﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Data.SqlClient;

namespace Pharmacy_management_system
{
    public partial class Form4 : Form
    {
        public Form4(string row1,int zhuangtai)
        {
            InitializeComponent();
            ht= row1;
            zt = zhuangtai;
            dny.Add(pingjia1_1); dny.Add(pingjia1_2); dny.Add(pingjia1_3); dny.Add(pingjia1_4);
            dny.Add(pingjia1_5); dny.Add(pingjia1_6); dny.Add(pingjia1_7); dny.Add(pingjia2_1);
            dny.Add(pingjia2_2); dny.Add(pingjia2_3); dny.Add(pingjia2_4); dny.Add(pingjia2_5);
            dny.Add(pingjia3_1); dny.Add(pingjia3_2); dny.Add(pingjia3_3);
            Label[] label1 = new Label[3] { label415, pingjiajg4, label416 };
            RadioButton[] radiobutton1 = new RadioButton[2] { radioButton32, radioButton31 };
            zhiliaoyongyaofp ft = new zhiliaoyongyaofp();
            ft.Therapeuticusepj(SQL.constr, zhuangtai, label1, radiobutton1, row1, dny, textBox11);
        }
        string ht;
        int zt;
        ArrayList dny = new ArrayList();
        private void button44_Click(object sender, EventArgs e)
        {
            panel25.Enabled = true;
        }

        private void button43_Click(object sender, EventArgs e)
        {
            string row1 = ht;
            using (SqlConnection sql = new SqlConnection(SQL.constr))
            {
                sql.Open();
                SqlCommand one = sql.CreateCommand();
                one.CommandText = "select user_name,time,i_level,c_question from zl_main where case_id = '" + row1 + "'";
                if (one.ExecuteScalar() != null)
                {
                    zt = 1;
                }
                else { zt = 0; }
                if (zt == 1)
                {
                    one.CommandText = "delete from zl_main where case_id ='" + row1 + "'";
                    one.ExecuteScalar();
                    one.CommandText = "delete from zl_detail where case_id ='" + row1 + "'";
                    one.ExecuteScalar();
                }
                int i = 0;
                string ss = " ";
                if (radioButton31.Checked)
                {
                    i = 0;
                    ss = "合理";
                }
                else if (radioButton32.Checked)
                {
                    i = 1;
                    ss = "不合理";
                }
                string s;
                one.CommandText = "INSERT INTO zl_main(case_id,user_id,user_name,time,i_level,c_level,c_question) VALUES('" + row1.Trim() + "'," + 1 + ",'" + "管理员" + "','" + DateTime.Now.Date.ToString("yyyy-MM-dd") + "'," + i.ToString() + ",'" + ss.Trim().ToString() + "','" + textBox11.Text.Trim().ToString() + "')";

                one.ExecuteScalar();
                foreach (CheckBox d in dny)
                {
                    if (d.Checked)
                    {
                        s = d.Name.ToString().Replace("pingjia", "");
                        one.CommandText = "insert into zl_detail(case_id,evl_id,evl_desc)values('" + row1.ToString() + "','" + s + "','" + d.Text.ToString() + "')";
                        one.ExecuteScalar();
                    }
                }
            }
            panel25.Enabled = false;
        }

        private void radioButton31_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton31.Checked == true)
            {
                panel37.Enabled = false;
                panel35.Enabled = false;
                panel26.Enabled = false;
                panel27.Enabled = false;
            }
        }

        private void radioButton32_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton32.Checked == true)
            {
                panel37.Enabled = true;
                panel35.Enabled = true;
                panel26.Enabled = true;
                panel27.Enabled = true;
            }
        }
    }
}
